<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="text" placeholder="请输入数据" id="fsVal">
    <button id="addFs">添加数据</button>
    <button id="removeFs">删除数据</button>
    <button id="getFs">获取数据</button>
    <script src="jquery-1.12.3.min.js"></script>
    <script>
        $(function(){
            var data={
                command:'',
                argument:''
            }
            $('#addFs').on('click',function(){
                data.command='add';
                data.argument=$('#fsVal').val();
                $('#fsVal').val('');
                changeFs(data);
            })
            $('#removeFs').on('click',function(){
                data.command='remove';
                data.argument='';
                changeFs(data);
            })
            function changeFs(value){
                $.ajax({
                    url:'http://localhost:4500/changeFs',
                    type:'post',
                    data:{
                        command:value.command,
                        argument:value.argument
                    },
                    success:function(res){
                        if(res=='add_ok'){
                            console.log('数据添加成功');
                        }else{
                            console.log('数据删除成功');
                        }
                    }
                })
            }
            $('#getFs').on('click',function(){
                $.ajax({
                    url:'http://localhost:4500/getFs',
                    type:'get',
                    success:function(res){
                        if(res!=''){
                            console.log(res);
                        }else{
                            console.log('数据为空');
                        }
                    }
                })
            })
        })
    </script>
</body>
</html>